package com.cryptoneedle.garden.service.dolphin;

import com.cryptoneedle.garden.service.util.ConfigUtil;
import org.apache.dolphinscheduler.client.DolphinSchedulerClient;
import org.apache.dolphinscheduler.client.model.common.Result;
import org.apache.dolphinscheduler.client.model.response.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>description:  </p>
 *
 * @author CryptoNeedle
 * @date 2025-11-05
 */
@Service
public class DolphinApiService {

    @Autowired
    private DolphinSchedulerClient dolphinSchedulerClient;

    @Autowired
    private ConfigUtil configUtil;

    public Long getUserCode() {
        Result<User> userInfo = dolphinSchedulerClient.user().getUserInfo();
        if (!userInfo.isSuccess()) {
            throw new RuntimeException("Failed to get DolphinScheduler user info");
        }
        return (long) userInfo.getCode();
    }
}